# Maintainer: Jelle van der Waa <jelle@archlinux.org>

pkgname=hey
pkgver=0.1.4
pkgrel=5
pkgdesc='HTTP load generator'
url="https://github.com/rakyll/hey"
arch=(loong64 x86_64)
license=('GPL')
depends=('glibc')
makedepends=('go')
source=($pkgname-$pkgver.tar.gz::https://github.com/rakyll/hey/archive/v$pkgver.tar.gz
        0001-Handle-Request.Host-containing-the-server-port.patch)
sha512sums=('f71ad13c401e9c9c45e1176924de49eb33df9b180dc10907997d1e500a4e5c6e28dd0293cef5d3fe8fabf0bfbade353938327bf3fce894c271209ec86e265ead'
            '97c2e54d4f9b67c8beda5b3c034e501cdec9d6636bfaaf7d33a27927c96915b73906400dc2a17888144a4748a0f37462ccd2c90b35ca4f3221f3a410cf81af16')

prepare() {
  cd $pkgname-$pkgver
  patch -Np1 -i ${srcdir}/0001-Handle-Request.Host-containing-the-server-port.patch
}

build() {
  cd $pkgname-$pkgver
  go build \
    -trimpath \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-linkmode external -extldflags \"${LDFLAGS}\"" \
    .
}


package() {
  cd $pkgname-$pkgver
  install -Dm755 $pkgname "$pkgdir"/usr/bin/$pkgname
}
